﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shove.Web.UI;

public partial class UserControls_MemberHomePage : UCBase
{
    public UserControls_MemberHomePage()
    {
        Name = "会员中心首页";

        swpas = new ShoveWebPartAttribute[14];

        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1000", 759, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("图片单元格宽度", "1,1000", 170, "图片单元格宽度");
        swpas[2] = new ShoveWebPartAttribute_Int("图片的宽度", "1,500", 150, "图片的宽度");
        swpas[3] = new ShoveWebPartAttribute_Int("图片的高度", "1,500", 115, "图片的高度");
        swpas[4] = new ShoveWebPartAttribute_Int("标题/点击查看行高", "1,300", 23, "订单/点击查看标题行高");

        swpas[5] = new ShoveWebPartAttribute_Text("图片CSS样式", "", "black12", "图片CSS样式");
        swpas[6] = new ShoveWebPartAttribute_Text("标题的CSS样式", "", "black12", "标题的CSS样式");
        swpas[7] = new ShoveWebPartAttribute_Text("点击查看的CSS样式", "", "blue12", "点击查看的CSS样式");

        swpas[8] = new ShoveWebPartAttribute_Image("订单图片", "", "images/UserControls/user_icon_1.jpg", "订单图片");
        swpas[9] = new ShoveWebPartAttribute_Image("我的订单标题背景图片", "", "images/UserControls/bg_hui_23_2.jpg", "我的订单标题的背景图片");
        swpas[10] = new ShoveWebPartAttribute_Image("商品评论图片", "", "images/UserControls/user_icon_2.jpg", "商品评论");
        swpas[11] = new ShoveWebPartAttribute_Image("商品咨询", "", "images/UserControls/user_icon_3.jpg", "商品咨询");
 
        swpas[12] = new ShoveWebPartAttribute_Color("图片单元格颜色", "#CCCCCC", "图片单元格颜色");
        swpas[13] = new ShoveWebPartAttribute_Text("个数CSS样式", "", "red", "个数CSS样式");
    }

    private void InitLayOut()
    {
        tabctr.Width = swpAttributes[0];
        tabctr.Style.Add(HtmlTextWriterStyle.BorderColor,swpAttributes[12]);
        tab1.Width = swpAttributes[1];
        tab1.BgColor = swpAttributes[12];

        tdimg1.Attributes.Add("class", swpAttributes[5]);
        img1.Height = Shove._Convert.StrToInt(swpAttributes[3], 115);
        img1.Width = Shove._Convert.StrToInt(swpAttributes[2], 150);
        img1.Src = "~/" + swpAttributes[8];

        tdOrder1.Height = swpAttributes[4];
        tdOrder1.Attributes.Add("class", swpAttributes[6]);
        tdOrder1.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url(\'" + swpAttributes[9] + "\')");
        MyOrder.Attributes.Add("class", swpAttributes[13]);

        tdlook1.Height = swpAttributes[4];
        tdlook1.Attributes.Add("class", swpAttributes[7]);

        //第2图片
        tab2.Width = swpAttributes[1];
        tab2.BgColor = swpAttributes[12];

        tdimg2.Attributes.Add("class", swpAttributes[5]);
        img2.Height = Shove._Convert.StrToInt(swpAttributes[3], 115);
        img2.Width = Shove._Convert.StrToInt(swpAttributes[2], 150);
        img2.Src = "~/" + swpAttributes[10];

        tdcomment.Height = swpAttributes[4];
        tdcomment.Attributes.Add("class", swpAttributes[6]);
        tdcomment.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url(\'" + swpAttributes[9] + "\')");
        GoodComment.Attributes.Add("class", swpAttributes[13]);

        tdlook2.Height = swpAttributes[4];
        tdlook2.Attributes.Add("class", swpAttributes[7]);

        //第3图片
        tab3.Width = swpAttributes[1];
        tab3.BgColor = swpAttributes[12];

        tdimg3.Attributes.Add("class", swpAttributes[5]);
        img3.Height = Shove._Convert.StrToInt(swpAttributes[3], 115);
        img3.Width = Shove._Convert.StrToInt(swpAttributes[2], 150);
        img3.Src = "~/" + swpAttributes[11];

        tdConsult.Height = swpAttributes[4];
        tdConsult.Attributes.Add("class", swpAttributes[6]);
        tdConsult.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url(\'" + swpAttributes[9] + "\')");
        GoodConsult.Attributes.Add("class", swpAttributes[13]);

        tdlook3.Height = swpAttributes[4];
        tdlook3.Attributes.Add("class", swpAttributes[7]);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["CurrentPage"] = null;
        }
        if (_Customer == null)
        {
            Response.Redirect("Default.aspx?PN=Login");
        }
        else
        {
            long ShopID = _Site.ID;
            DataTable dt = new DAL.Views.V_Shop_SalesMaster().Open("", "SalesType = 4 and CustomerID = " + _Customer.ID.ToString() + " and ShopID = " + _Site.ID.ToString(), "");

            //显示我的订单数目
            if (dt != null && dt.Rows.Count > 0)
            {
                MyOrder.InnerText = dt.Rows.Count.ToString();
            }

            //显示我的评论数目
            dt = new DAL.Views.V_Site_GoodComment().Open("", "ShopID=" + _Site.ID + " and CustomerID=" + _Customer.ID + " and Type=2", "");

            if (dt != null && dt.Rows.Count > 0)
            {
                GoodComment.InnerText = dt.Rows.Count.ToString();
            }

            //显示我的咨询数目
            dt = new DAL.Views.V_Site_GoodComment().Open("", "ShopID=" + _Site.ID + " and CustomerID=" + _Customer.ID + " and Type=1", "");

            if (dt != null && dt.Rows.Count > 0)
            {
                GoodConsult.InnerText = dt.Rows.Count.ToString();
            }

            ////显示我的收货通知数目
            //dt = BLL.sales_MasterBLL.GetSalesMasterByCustomerID(((Entity.Customer)_Customer).Id, shopID);

            //if (dt != null && dt.Rows.Count > 0)
            //{
            //    ReceiveGood.InnerText = dt.Rows.Count.ToString();
            //}

            InitLayOut();
        }
    }
}
